package thread;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import protocol.DataPackage;
import protocol.JsonPackage;

public class SendPackageThread extends Thread{
	private DataPackage pack;
	private BufferedReader reader;
	private BufferedWriter writer;
	
	
	public SendPackageThread(DataPackage pack, BufferedReader reader,
			BufferedWriter writer) {
		this.pack = pack;
		this.reader = reader;
		this.writer = writer;
	}


	@Override
	public void run() {
		try {
//			writer.writeObject(pack);
			writer.write(new JsonPackage(pack).getJsonString() + "\n");
			writer.flush();
		} catch (IOException e) {
			System.out.println("客户端发送包失败了");
			e.printStackTrace();
		}
		
		System.out.println("客户端发送信息完毕");
	}
}
